#!/usr/bin/python
# -*- coding: UTF-8 -*-
import logging

# 创建logger记录器
logger = logging.getLogger('simple_example')
logger.setLevel(logging.DEBUG)

# 创建一个控制台处理器，并将日志级别设置为debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)


# 创建formatter格式化器
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - [%(created)f | %(filename)s | %(funcName)s | %(levelno)s | %(lineno)d | %(module)s| %(name)s |%(pathname)s | %(process)d |%(processName)s]- %(message)s')

# 将formatter添加到ch处理器
ch.setFormatter(formatter)

# 将ch添加到logger
logger.addHandler(ch)

# 然后就可以开始使用了!
logger.debug('debug message')
logger.info('info message')
logger.warn('warn message')
logger.error('error message')
logger.critical('critical message')